﻿using PermissionAuthenticationDemo.Common.Enum;

namespace PermissionAuthenticationDemo.Common
{
    public class ApiResult<T>
    {
        public ResultStatus status { get; set; }

        public string message { get; set; }

        public int total { get; set; }

        public T data { get; set; }

        public ApiResult(ResultStatus status, string message, int total, T data = default(T))
        {
            this.status = status;
            this.message = message;
            this.total = total;
            this.data = data;

        }

        //使用静态方法，用于快速创建成功的结果
        public static ApiResult<T> Success(T data, int total, string message = "操作成功")
        {
            return new ApiResult<T>(ResultStatus.Success, message, total, data);
        }

        public static ApiResult<T> Error(T data, int total, string message = "操作失败")
        {
            return new ApiResult<T>(ResultStatus.Error, message, total, data);
        }
    }
}
